const { Sequelize, Model } = require('sequelize')
const { sequelize } = require('../../core/db')

class ProCate extends Model {}

ProCate.init({
  id: {
    type: Sequelize.INTEGER,
    autoIncrement: true,
    primaryKey: true
  },
  name: Sequelize.STRING(30),
  pid: {
    type: Sequelize.INTEGER, 
    defaultValue: 0
  },
  orderNum: {
    type: Sequelize.INTEGER,
    defaultValue: 1
  }
}, {
  sequelize
})

ProCate.sync({force: true}).then(() => {
  return ProCate.bulkCreate([
    { name: '同步带轮', pid: 0, orderNum: 1 },
    { name: '气涨轴', pid: 0, orderNum: 2 },
    { name: '同步带', pid: 0, orderNum: 3 }
  ])
})

module.exports = ProCate